import time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

#1、打开浏览器 --- 驱动管理
ChromeIns = ChromeDriverManager().install()

#创建谷歌浏览器驱动对象
driver = webdriver.Chrome(service=Service(ChromeIns))

driver.get("https://www.baidu.com")

#清除文本内容
#连续的send_keys()会将多次输入的内容拼接在一起，若想重新输入,需要使用清除方法
driver.find_element(By.CSS_SELECTOR,"#chat-textarea").send_keys("迪丽热巴")
time.sleep(2)
driver.find_element(By.CSS_SELECTOR,"#chat-textarea").clear() #报错？？？？
time.sleep(2)
driver.find_element(By.CSS_SELECTOR,"#chat-textarea").send_keys("古力娜扎")

driver.quit()